We have decided to take a leap and try plot_ly and knit to html output for this milestone. The html page is hosted as Github Pages and is accessible in this address: https://tin6150.github.io/phw251_group_z/milestone4_groupZ.html
(This code block omitted for brevity, please refer to source at our github repo )
Data needed to make decision: -which counties share all 3 attributes: low pop(rural), high median age, & high proportion of renters vs homeowners -which 5 counties have highest mortality rates due to chronic illness -what counties have received little to no funding recently? —not quite sure about this one
Table 1 shows that the 5 counties of Siskiyou, Inyo, Mariposa, Plumas and Modoc have low population density (they qualify as Rural per National Rural Development Partnership’s definition), have a high median age, and fairly high ratio of renters. More importantly, they have one of the highest percentage of chronic diseases, and no HCAI fundings that are “In Closure” as of 2022-08-11.
Note that the latest population data is from 2012.
viz_focus = viz_fund_dem_chron %>%
filter( rural_class == "rural",
high_med_age == TRUE
##high_rental == TRUE
)
focus_table = viz_focus %>%
select( County,
pop12_sqmi,
#rural_class,
#low_pop,
med_age,
#high_med_age,
rent_own_ratio,
#high_rental,
pct, # prevalence,
Numeric_Cost,
#fund_per_cap,
#`Number of OSHPD Projects`,
) %>%
arrange( desc( pct )) %>%
rename(
`Pop Density` = pop12_sqmi,
`Median Age` = med_age,
`Rent:Own Ratio` = rent_own_ratio,
`% Chronic` = pct,
`HCAI Fund in 2022` = Numeric_Cost
) %>%
head( 5 )
kable( focus_table,
booktabs=T,
digits=c(0,1,1,2,2,0),
format.args=list(big.mark=','),
caption = "Rural Counties with high median age, rental ratio, and chronic disease rate",
)
| County | Pop Density | Median Age | Rent:Own Ratio | % Chronic | HCAI Fund in 2022 |
|---|---|---|---|---|---|
| Siskiyou | 7.1 | 46.8 | 0.54 | 2.86 | 0 |
| Inyo | 1.8 | 45.5 | 0.57 | 1.88 | 0 |
| Mariposa | 12.6 | 49.2 | 0.47 | 1.72 | 0 |
| Plumas | 7.7 | 49.5 | 0.44 | 1.69 | 0 |
| Modoc | 2.3 | 46.0 | 0.46 | 1.43 | 0 |
The following boxplot summarizes chronic disease mortality rates from all CA counties, grouped according to HCAI funding amounts for in closure projects as of August 2022. The funding amounts were categorized as “high” if they were above the mean amount, low if they were below the mean, and “no funding” if no funding for in closure projects was reported.
(Audrey, so what is graph telling the audience?)
funding_chronic <- funding_data %>%
filter( `OSHPD Project Status` == "In Closure") %>%
filter( `Data Generation Date` == as_date( "2022-08-11")) %>%
mutate(funding_amount = case_when(
Numeric_Cost > 12239849 ~ "High Funding",
Numeric_Cost == 0 ~ "No Funding",
Numeric_Cost < 12239849 ~ "Low Funding"
)) %>%
inner_join(demographics_chronic, funding_data_all_counties, by = "County") %>%
select(pct, County, funding_amount, rural_class, Numeric_Cost)
plot_ly(
funding_chronic,
y=~pct,
color= ~funding_amount,
type="box"
) %>%
layout(
title="Chronic Disease Mortality Rates & HCAI Funding",
yaxis=list(title="Chronic Disease Rate"))
counties_funding_comp = funding_data %>%
filter( `OSHPD Project Status` == "In Closure" ) %>%
filter( `Data Generation Date` ==
as_date( "2022-08-11" )
#as_date( "2020-01-01" )
#as_date( "2016-01-01" )
) %>%
arrange( Numeric_Cost )
#fig2 = plot_ly( data = funding_data_1county ) %>%
#fig2 = plot_ly( data = funding_data_selected_counties ) %>%
fig2 = plot_ly( data = counties_funding_comp ) %>%
add_trace(x = ~`County`,
y = ~Numeric_Cost,
type = 'bar',
name = 'Funding across 58 counties',
marker = list(color = 'rgb(187, 216, 228)'),
hoverinfo = "text",
text = ~paste(round(Numeric_Cost, 0), ' US$') ) %>%
layout(
title="Funding across 58 counties"
)
fig2
Below is a graph of Mortality Rate for Chronic diseases (as defined by CDC) across all 58 California counties. The 5 counties of focus have Mortality rates of: (TBD)
chronic_focus_counties = demographics_chronic %>%
mutate( focusCounty = if_else(
County %in% selected_counties,
TRUE,
FALSE
) ) %>%
mutate( ctyColor = case_when(
County == "Siskiyou" ~ "red",
County == "Inyo" ~ "darkorange" ,
County == "Mariposa" ~ "blue",
County == "Plumas" ~ "darkblue",
County == "Modoc" ~ "darkcyan",
TRUE ~ "darkyellow"
) )
fig3 = plot_ly( data = chronic_focus_counties ) %>%
add_trace(x = ~`County`,
y = ~pct,
type = 'bar',
#color = ~focusCounty,
color = ~ctyColor,
name = 'Chronic Mortality Rates by Counties',
marker = list(color = 'rgb(187, 216, 228)'),
hoverinfo = "text",
text = ~paste('County: ', County, '<BR>Mortality Rate:', round(pct, 1)) ) %>%
layout(
title = "Chronic Mortality Rates by Counties",
yaxis = list( title="% Mortality Rate" )
)
fig3